<template>
    <div>
        <span style="font-size:25px">已登记信息</span>
        <el-divider></el-divider>
        <div class="container">
                <el-table :data="userInfo"
                border 
                class="table"
                ref="tableRef"
                header-cell-class-name="table-header">
                <el-table-column prop="user_id" label="用户ID"></el-table-column>
                <el-table-column prop="college" label="学院"></el-table-column>
                <el-table-column prop="name" label="姓名"></el-table-column>
                <el-table-column prop="health" label="健康状况"></el-table-column>
                <el-table-column prop="temperature" label="体温"></el-table-column>
                <el-table-column prop="outside" label="是否外出"></el-table-column>
                <el-table-column prop="time" label="填报时间"></el-table-column>
                <el-table-column prop="work" label="工作状态"></el-table-column>
                <el-table-column prop="remark" label="备注"></el-table-column>
                </el-table>
        </div>
        <el-divider></el-divider>
        <span style="font-size:25px">未登记信息</span>
        <el-divider></el-divider>
        <div class="container">
            <el-table :data="userInfo1"
                border 
                class="table"
                ref="tableRef"
                header-cell-class-name="table-header">
                <el-table-column prop="user_id" label="用户ID"></el-table-column>
                <el-table-column prop="college" label="学院"></el-table-column>
                <el-table-column prop="name" label="姓名"></el-table-column>
                <el-table-column prop="un_register" label="未登记次数"></el-table-column>
                <el-table-column prop="time" label="最近一次未登记时间"></el-table-column>
            </el-table>
        </div>

    </div> 
</template>

<script>
import historyRegister from '@/api/historyRegister'
import moment from 'moment'
export default {
    name: 'historyRegister',
    data() {
        return {
            id:'',
            userInfo:[],
            userInfo1:[]
        }
    },
    created() {
        this.getUserByName();
        this.getUnRegisterUserByName();
    },
    methods: {
        getUserByName() {
            this.id = localStorage.getItem('ms_userId')
            
                historyRegister.getMyInfo(this.id)
                .then(response=>{
                    this.userInfo = response.data;
                    var userInfoDetailList = [];
                    if (this.userInfo){
                        this.userInfo.forEach(u=>{
                            var detail={
                                user_id:u.user_id,
                                college:u.college,
                                name:u.name,
                                health:u.health,
                                temperature:u.temperature,
                                outside:u.outside,
                                time:moment(u.time).format('YYYY年MM月DD日 HH:mm'),
                                work:u.work,
                                remark:u.remark
                            }
                        userInfoDetailList.push(detail);
                        })
                        this.userInfo=userInfoDetailList;
                    }
                })
        },
        getUnRegisterUserByName() {
            this.id = localStorage.getItem('ms_userId')
            
                historyRegister.getUnRegisterMyInfo(this.id)
                .then(response=>{
                    this.userInfo1 = response.data;
                    var userInfoDetailList = [];
                    if (this.userInfo1){
                        this.userInfo1.forEach(u=>{
                            var detail={
                            user_id:u.user_id,
                            college:u.college,
                            name:u.name,
                            un_register:u.unregistered,
                            time:moment(u.unregistered_time).format('YYYY年MM月DD日 HH:mm'),
                            }
                            console.log(detail.un_register)
                        userInfoDetailList.push(detail);
                        })
                        this.userInfo1=userInfoDetailList;
                    }
                })
            }

        }

}


</script>
<style scoped>
.handle-box{
    margin-bottom: 20px;
}
.table{
    width: 100%;
    font-size: 14px;
}
</style>
